{block name=body} {* Define the function *} {function name=render_product_list cnt=0 level=0}
<div class="featured-products">
    <div class="category-wrapper">
        {foreach $items.listings as $cat}
        <div>
            {foreach $cat.products as $item} {if $item.product_flag1 eq 1} {include file='product.tpl' cnt=$cnt++} {/if} {/foreach}
        </div>
        {/foreach}
    </div>
    <div class="text-center">
        <button class="btn btn-info" onclick="$('.featured-products').toggle(); $('html,body').animate({ scrollTop : $('#products').offset().top });">加载更多产品</button>
    </div>
</div>
<div class="featured-products" style="display:none;">
    {foreach $items.listings as $cat}
    <div class="category-wrapper featured-products" style="display:none;">
        <h3>{$cat.listing_name}</h3>
        <div>
            {foreach $cat.products as $item} {include file='product.tpl' cnt=$cnt++} {/foreach}
        </div>
    </div>
    {/foreach}
</div>
{/function}
<div class="row">
    <div class="col-sm-9" id="selector">
        <div class="btn-group btn-group-justified" data-toggle="buttons" style="padding:0 5px 0 0;">
            <label id="enrolment-lbl-S" class="enrolment-lbl btn btn-grey {if $type eq 'S'}active{/if}" {if $type eq 'T'}style="display:none" {/if}>
                <input type="radio" name="options" value="newmember" id="newmember" {if $type neq 'T'}checked{/if}> 标准课程
            </label>
            <label id="enrolment-lbl-T" class="enrolment-lbl btn btn-grey {if $type eq 'T'}active{/if}" {if $type eq 'S'}style="display:none" {/if}>
                <input type="radio" name="options" value="trial" id="trial" {if $type eq 'T'}checked{/if}> 体验课程
            </label>
        </div>
    </div>
</div>
<div class="row" id="enrolment-wrapper" {if !$type}style="display:none" {/if}>
    <div class="col-sm-9">
        <div class="panel-group" id="accordion">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h4 class="panel-title">
						<a data-toggle="collapse" data-parent="#accordion" href="#selectClass">
							选择课程
							<span class="glyphicon glyphicon-ok pull-right" id="checked-step1" {if $step lte 1}style="display:none;"{/if}> </span>
							<span class="glyphicon glyphicon-unchecked pull-right" id="unchecked-step1" {if $step gt 1}style="display:none;"{/if}></span>
						</a>
					</h4>
                </div>
                <div id="selectClass" class="panel-collapse collapse {if $step eq 1}in{/if} step1">
                    <div class="panel-body">
                        {if $step gt 1} {include file='classterm-filters.tpl' form_id='search-classes-form-new' form_method='post' action='getClasstermpanelTemplate'} {else} {include file='classterm-filters.tpl'} {/if}
                        <hr>
                        <div id="search-classes-form-new-result" style="display:none;">
                            {include file='classterm-panel.tpl'}
                        </div>
                        <div class="text-center">
                            <button id="step1-btn" type="button" class="btn btn-default side-padding" onclick="GoToStep(2)">下一步</button>
                        </div>
                    </div>
                </div>
            </div>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h4 class="panel-title">
						<a data-toggle="collapse" data-parent="#accordion" href="#parentInfo">
							会员信息
							<span class="glyphicon glyphicon-ok pull-right" id="checked-step2" {if $step lte 2}style="display:none;"{/if}></span>
							<span class="glyphicon glyphicon-unchecked pull-right" id="unchecked-step2" {if $step gt 2}style="display:none;"{/if}></span>
						</a>
					</h4>
                </div>
                <div id="parentInfo" class="panel-collapse collapse {if $step eq 2}in{/if} step2">
                    <div class="panel-body">
                        <form class="form-horizontal" id="add-member-form" role="form" accept-charset="UTF-8" action="" method="post" {if $step lte 1}style="display:none;" {/if}>
                            <input type="hidden" value="addMember" name="action" id="action" />
                            <input type="hidden" name="formToken" value="{$token}" />
                            <input type="hidden" name="update_flag" value="" class="update_flag" /> {include file='member.tpl' newMember='true'}
                            <div class="text-center">
                                <button id="step2-btn" type="submit" class="btn btn-default side-padding">下一步</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h4 class="panel-title">
						<a data-toggle="collapse" data-parent="#accordion" href="#studentInfo">
							学生信息
							<span class="glyphicon glyphicon-ok pull-right" id="checked-step3" {if $step lte 3}style="display:none;"{/if}></span>
							<span class="glyphicon glyphicon-unchecked pull-right" id="unchecked-step3" {if $step gt 3}style="display:none;"{/if}></span>
						</a>
					</h4>
                </div>
                <div id="studentInfo" class="panel-collapse collapse {if $step eq 3}in{/if} step3">
                    <div class="panel-body">
                        <div id="student-form-wrapper" {if $step eq 2}style="display:none;" {/if}>
                            <form class="form-horizontal" id="student-form" role="form" accept-charset="UTF-8" action="" method="post">
                                <input type="hidden" value="setStudent" name="action" />
                                <input type="hidden" name="formToken" id="formToken" value="{$token}" />
                                <div id="student-wrapper">
                                    {if $type eq 'T'}{assign var='trial_flag' value=1}{else}{assign var='trial_flag' value=0}{/if} {assign var='cnt' value=0} {if $students} {foreach $students as $student} {if $student}{include file='student.tpl' user_id=$user.user_id cnt=$cnt++ trial_flag=$trial_flag newmember=1}{/if} {/foreach} {/if}
                                </div>
                                <div class=" col-sm-offset-3 error-alert" style="display:none;">
                                    <div class="alert alert-danger fade in ">
                                        <button class="close" aria-hidden="true" type="button" onclick="$(this).closest('.error-alert').fadeOut('slow');">&times;</button>
                                        <strong></strong>
                                    </div>
                                </div>
                                <input type="hidden" name="cnt" id="cnt" value="{$cnt}" />
                                <input type="hidden" name="trial_flag" id="student-trial-flag" value="{$trial_flag}" />
                                <div class="text-center">
                                    <button type="button" class="btn btn-default" onclick="AddStudent('student-form')">添加学生</button>
                                    <button id="step3-btn" type="submit" class="btn btn-default side-padding">下一步</button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
            <div class="panel panel-default not-trial" {if $type eq 'T'}style="display:none;" {/if}>
                <div class="panel-heading">
                    <h4 class="panel-title">
						<a data-toggle="collapse" data-parent="#accordion" href="#products">
							产品
							<span class="glyphicon glyphicon-ok pull-right" id="checked-step4" {if $step lte 4}style="display:none;"{/if}></span>
							<span class="glyphicon glyphicon-unchecked pull-right" id="unchecked-step4" {if $step gt 4}style="display:none;"{/if}></span>
						</a>
					</h4>
                </div>
                <div id="products" class="panel-collapse collapse {if $step eq 4}in{/if} step4">
                    <div class="panel-body">
                        {call name=render_product_list items=$products}
                        <div class="text-center">
                            &nbsp;
                            <hr>
                            <button id="step4-btn" type="button" class="btn btn-default side-padding" onclick="GoToStep(5)">下一步</button>
                        </div>
                    </div>
                </div>
            </div>
            <div class="panel panel-default not-trial" {if $type eq 'T'}style="display:none;" {/if}>
                <div class="panel-heading">
                    <h4 class="panel-title">
						<a data-toggle="collapse" data-parent="#accordion" href="#extras">
							其他费用 / 折扣
							<span class="glyphicon glyphicon-ok pull-right" id="checked-step5" {if $step lte 5}style="display:none;"{/if}></span>
							<span class="glyphicon glyphicon-unchecked pull-right" id="unchecked-step5" {if $step gt 5}style="display:none;"{/if}></span>
						</a>
					</h4>
                </div>
                <div id="extras" class="panel-collapse collapse {if $step eq 5}in{/if} step5">
                    <div class="panel-body">
                        <form class="form-horizontal" id="additional-form" role="form" accept-charset="UTF-8" action="" method="post">
                            <input type="hidden" value="setAdditional" name="action" />
                            <input type="hidden" name="formToken" id="formToken" value="{$token}" />
                            <div class="form-group">
                                <label class="col-sm-3 control-label">描述</label>
                                <div class="col-sm-9">
                                    <input type="text" value="{$additional.description}" class="form-control" id="additional-input" name="additional[description]">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">金额 ({$CURRENCY_SYMBOL})</label>
                                <div class="col-sm-9">
                                    <input type="text" value="{$additional.amount}" class="form-control double" name="additional[amount]" onchange="if(this.value){ $('#additional-input').attr('required','required') } else { $('#additional-input').removeAttr('required') }">
                                    <span class="help-block">(-) for discounts</span>
                                </div>
                            </div>
                            <div class="text-center">
                                <button id="step5-btn" type="submit" class="btn btn-default side-padding">下一步</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h4 class="panel-title">
						<a data-toggle="collapse" data-parent="#accordion" href="#payment">
							<span id="step6-tab-name">{if $type eq 'T'}确认{else}付款{/if}</span>
							<span class="glyphicon glyphicon-ok pull-right" id="checked-step6" {if $step lte 6}style="display:none;"{/if}></span>
							<span class="glyphicon glyphicon-unchecked pull-right" id="unchecked-step6" {if $step gt 6}style="display:none;"{/if}></span>
						</a>
					</h4>
                </div>
                <div id="payment" class="panel-collapse collapse {if $step eq 6}in{/if} step6">
                    <div class="panel-body">
                        <div id="payment-wrapper" {if $step lte 5}style="display:none;" {/if}>
                            <form class="form-horizontal" id="payment-form" role="form" accept-charset="UTF-8" action="" method="post">
                                <input type="hidden" value="PlaceOrder" name="action" />
                                <input type="hidden" name="formToken" id="formToken" value="{$token}" />
                                <div class="not-trial" id="payment-methods-wrapper" {if $step eq 6 && $type eq 'T'}style="display:none;" {/if}>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">总计 ({$CURRENCY_SYMBOL})*</label>
                                        <div class="col-sm-9">
                                            {assign var='total' value=$totals.total} {if $additional.amount}{assign var='total' value=$additional.amount+$total}{/if}
                                            <input style="display:inline-block" type="text" value="{$total}" data-amount="{$total}" onchange="SetPartialPayment()" id="payment-amount" class="cc-req form-control double" name="cc[amount]" {if $type neq 'T'}required{/if}>
                                            <span class="ccsurchage"> + 2% 信用卡附加费 = </span> <span class="ccsurchage"><b id="cctotal">{$CURRENCY_SYMBOL}0</b></span>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">付款类型: </label>
                                        <!-- <div class="col-sm-3 form-text-element">
								      	    <input type="radio" value="cc" checked name="payment-method"> 信用卡
								        </div> -->
                                        <div class="col-sm-3 form-text-element">
                                            <input type="radio" value="bt" checked name="payment-method"> 银行转账
                                        </div>
                                    </div>
                                    <div class="form-group" id="nextpayment-wrapper" style="display:none;">
                                        <label class="col-sm-3 control-label">Next payment*</label>
                                        <div class="col-sm-4">
                                            <input class="form-control dates datepicker nextpayment" type="text" value="" name="from-payment" id="from-payment" onchange="setDateValue('nextpayment',this.value);">
                                            <input type="hidden" class="nextpayment" value="" name="nextpayment" id="nextpayment">
                                            <script>
                                            $(function() {
                                                $("#from-payment").datepicker({
                                                    changeMonth: true,
                                                    changeYear: true,
                                                    dateFormat: "dd/mm/yy",
                                                    onSelect: function(selectedDate) {
                                                        $("#nextpayment").val(convert_to_mysql_date_format(selectedDate));
                                                    }
                                                });
                                            });
                                            </script>
                                        </div>
                                    </div>
                                    <div id="cc-wrapper" class="hidden">
                                        <div class="form-group">
                                            <label class="col-sm-3 control-label" for="ccno">信用卡号*</label>
                                            <div class="col-sm-6">
                                                <input type="text" id="ccno" class="cc-req form-control" name="cc[number]" autocomplete="off" {if $type neq 'T'}required{/if}/>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-3 control-label" for="ccname">持卡人姓名*</label>
                                            <div class="col-sm-6">
                                                <input type="text" id="ccname" value="{if $user.gname}{$user.gname}{/if}{if $user.surname} {$user.surname}{/if}" class="cc-req form-control" name="cc[name]" autocomplete="off" {if $type neq 'T'}required{/if} />
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-3 control-label" for="ccmonth">到期时间*</label>
                                            <div class="col-sm-3">
                                                <select id="ccmonth" name="cc[month]" class="cc-select-req form-control {if $type neq 'T'}required{/if}">
                                                    <option value="">月</option>
                                                    <option value="01">01</option>
                                                    <option value="02">02</option>
                                                    <option value="03">03</option>
                                                    <option value="04">04</option>
                                                    <option value="05">05</option>
                                                    <option value="06">06</option>
                                                    <option value="07">07</option>
                                                    <option value="08">08</option>
                                                    <option value="09">09</option>
                                                    <option value="10">10</option>
                                                    <option value="11">11</option>
                                                    <option value="12">12</option>
                                                </select>
                                            </div>
                                            <div class="col-sm-3">
                                                <select id="ccyear" name="cc[year]" class="cc-select-req form-control {if $type neq 'T'}required{/if}">
                                                    {assign var=thisyear value=$smarty.now|date_format:"%Y"} {assign var=numyears value=$thisyear+20}
                                                    <option value="">年</option>
                                                    {for $year=$thisyear to $numyears}
                                                    <option value="{$year}">{$year}</option>
                                                    {/for}
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-3 control-label" for="cccsv">CSV*</label>
                                            <div class="col-sm-3">
                                                <input type="text" id="cccsv" name="cc[csv]" class="cc-req form-control" autocomplete="off" {if $type neq 'T'}required{/if} />
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-12 text-center" id="no-payment-required" style="display:none;">
                                    <b>不需要付款。</b>
                                    <br> &nbsp;
                                </div>
                                <div class="col-sm-offset-3 error-alert" style="display:none;">
                                    <div class="alert alert-danger fade in ">
                                        <button class="close" aria-hidden="true" type="button" onclick="$(this).closest('.error-alert').fadeOut('slow');">&times;</button>
                                        <strong></strong>
                                    </div>
                                </div>
                                <div class="text-center">
                                    <button id="step6-btn" type="submit" onclick="if($(this).closest('form').valid()){ $('#step6-btn').hide();$('#processing-div').show(); }" class="btn btn-default side-padding">{if $type eq 'T'}确认体验课{else}下单{/if}</button>
                                    <div style="display:none;" id="processing-div" class="btn btn-default side-padding">处理中...</div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--col-sm-9-->
    <div class="col-sm-3">
        <div class="panel panel-default" id="fixedinfo">
            <div class="panel-heading">
                <h4 class="panel-title">摘要</h4>
            </div>
            <div class="panel-body" id="cart-summary">
                {include file='shopping-cart.tpl'}
            </div>
            <div class="panel-footer">
                {if $paynow}
                <button type="button" onclick="FastConvert()" class="btn btn-default pull-right">立即支付</button>{/if}
                <form class="form-horizontal" id="reset-cart-form" method="post">
                    <input type="hidden" value="ResetCart" name="action" id="action" /> {if $resetRedirect}
                    <input type="hidden" value="/admin/members/new/{$user.user_id}" name="redirect" /> {/if}
                    <input type="hidden" name="formToken" value="{$token}" />
                    <button type="button" onclick="if (confirm('Do you want to reset the shopping cart?')) { $('#reset-cart-form').submit(); }" class="btn btn-default">重置</button>
                </form>
            </div>
        </div>
    </div>
</div>
{/block} {block name=tail}
<script type="text/javascript">
$(document).ready(function() {
{if $step eq 6}
	CheckPaymentMethod();
{/if}
	CheckPaymentRequired();

    $('#add-member-form').validate({
        onkeyup: false
    });
    $('#reg-email').rules("add", {
        uniqueEmail: {
            id: "{if $user.user_id}{$user.user_id}{else}0{/if}",
            table: "user"
        }
    });

    $('#student-form').validate({
        onkeyup: false
    });

    $('.product-forms').each(function() {
        $(this).validate({
            onkeyup: false,
        });
    });

    $('#additional-form').validate({
        onkeyup: false,
    });

    $('#payment-form').validate({
        onkeyup: false
    });

    $('#reset-cart-form').validate();

    $('.postcode').rules("add", {
        digits: true,
        minlength: 3
    });

    $('.double').rules("add", {
        number: true
    });

    $('#ccno').rules("add", {
        creditcard: true,
    });

    $('#cccsv').rules("add", {
        digits: true,
        minlength: 3
    });

});

$("input[name='options']").change(function() {
    $('#enrolment-wrapper').show('slow');
    $(".enrolment-lbl").hide();
    $("input[name='options']:checked").closest('label.enrolment-lbl').show();
    if ($("input[name='options']:checked").val() == 'trial') {
        $('.enrolment-type').val('T');
        $('.not-trial').hide('slow');
        $('.is-trial').show('slow');
        $('#step6-tab-name').html('Confirmation');
        $('#step6-btn').html('Add Trial');
        $('#student-trial-flag').val('1');
    } else {
        $('.enrolment-type').val('S');
        $('.not-trial').show('slow');
        $('.is-trial').hide('slow');
        $('#step6-tab-name').html('Payment');
        $('#step6-btn').html('Place Order');
        $('#student-trial-flag').val('0');
    }
});

$('#add-member-form').find('input').change(function() {
    $('#add-member-form').find('.update_flag').val('1');
}); $('#add-member-form').find('textarea').change(function() {
    $('#add-member-form').find('.update_flag').val('1');
}); $('#add-member-form').find('select').change(function() {
    $('#add-member-form').find('.update_flag').val('1');
});


$(window).load(function() {
    $('#search-classes-form-new-result').show();
});

$(window).scroll(function() {

    var y = $(this).scrollTop();
    if (y > $('#selector').offset().top) {
        $('#fixedinfo').addClass('shopping-fixed');
    } else {
        $('#fixedinfo').removeClass('shopping-fixed');
    }

});
</script>
{/block}
